package com.fmn.dots_final_i_hope;

import model.Player;

public class PlayerControl {

	/**
	 * This class creates 2 Player objects. Has two main functionalities - to
	 * change the current player and to know which player's turn is
	 */

	static Player p1 = new Player("player1");
	static Player p2 = new Player("player2");

	static int choosenRow = 3, choosenCol = 3;
	
	static int chosenPic1 = R.drawable.taken_square1;
	static int chosenPic2 = R.drawable.taken_square2;

	static int maxPointsPossible = choosenRow * choosenCol;
	
	public static String anounceWinner(){
		if(p1.getCurrentPoints() > p2.getCurrentPoints())
			return p1.getName();
		if(p2.getCurrentPoints() > p1.getCurrentPoints())
			return p2.getName();
		
		return "DRAW";
	}
	
	public static void nullPoints(){
		p1.setCurrentPoints(0);
		p2.setCurrentPoints(0);
	}

	public static boolean checkForEndGame() {
		if(p1.getCurrentPoints() + p2.getCurrentPoints() >= maxPointsPossible){	
			return true;
		}
		return false;
	}

	static Player currentPlayer = p1;

	public static void changePlayer() {
		if (currentPlayer == p1) {
			currentPlayer = p2;
		} else {
			currentPlayer = p1;
		}
	}

	public static Player getCurrentPlayer() {
		return currentPlayer;
	}

	public void setCurrentPlayer(Player currentPlayer) {
		this.currentPlayer = currentPlayer;
	}

}
